package org.zuel.lkq.controller;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.zuel.lkq.param.user.manage.QueryUserParam;
import org.zuel.lkq.param.user.manage.UserCreateParam;
import org.zuel.lkq.param.user.manage.UserDetailParam;
import org.zuel.lkq.param.user.manage.UserStatusParam;
import org.zuel.lkq.service.UserManageService;

@RestController
@Api(tags = "工单系统: 用户管理模块")
@RequestMapping(value="/user_manage")
public class UserManageController {

    private UserManageService userManageService;

    @Autowired
    public UserManageController(UserManageService userManageService) {
        this.userManageService = userManageService;
    }

    @ApiOperation(value = "查询存在的用户")
    @RequiresPermissions("user:query")
    @PostMapping(value = "/query")
    public Object queryExistUser(@RequestBody QueryUserParam param) {
        return userManageService.queryExistUser(param);
    }


    @ApiOperation(value = "审核某个用户")
    @RequiresPermissions("user:check")
    @PostMapping(value = "/check")
    public Object check(@RequestBody UserStatusParam param) {
        return userManageService.updateUserStatus(param);
    }

    @ApiOperation(value = "查看用户详情（编辑按钮）")
    @RequiresPermissions("user:detail")
    @PostMapping(value = "/get_user_detail")
    public Object getUserDetail(@RequestBody UserDetailParam param) {
        return userManageService.getUserDetail(param);
    }

    @ApiOperation(value = "编辑用户信息")
    @RequiresPermissions("user:edit")
    @PostMapping(value = "/edit")
    public Object edit(@RequestBody UserCreateParam param) {
        return userManageService.editExistUser(param);
    }

}
